/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package validator;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author Valentina
 */
public class FormValidator {

    private static final String PASSWORD_PATTERN = "^[a-zA-Z0-9_-]{6,20}";//"((?=.*\\d)(?=.*[a-z])(?=.*[A-Z])(?=.*[@#$%]).{6,20})";
    private static Pattern pattern = Pattern.compile(PASSWORD_PATTERN);
    private static Matcher matcher;

    public static Boolean validateRequiredField(String field) {
        Boolean isValidated = true;

        if (field != null && field.length() == 0) {
            isValidated = false;
        }

        return isValidated;
    }

    public static Boolean validatePasswordField(String password) {
        matcher = pattern.matcher(password);
        return matcher.matches();
    }
}